package com.mygame.common.log;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LogUtil {
	private static final Logger warn = LoggerFactory.getLogger("WarnLogger");
	private static final Logger info = LoggerFactory.getLogger("InfoLogger");
	private static final Logger debug = LoggerFactory.getLogger("DebugLogger");
	private static final Logger error = LoggerFactory.getLogger("ErrorLogger");
	private static final Logger exceptionLogger = LoggerFactory.getLogger("exceptionLogger");


	public static void debug(String msg) {
		debug.debug(msg);
	}

	public static void debug(String format, Object arg) {
		debug.debug(format, arg);
	}

	public static void debug(String format, Object arg1, Object arg2) {
		debug.debug(format, arg1, arg2);
	}

	public static void debug(String format, Object... arguments) {
		debug.debug(format, arguments);
	}

	public static void debug(String msg, Throwable t) {
		debug.debug(msg, t);
	}

	public static void info(String msg) {
		info.info(msg);
	}

	public static void info(String format, Object arg) {
		info.info(format, arg);
	}

	public static void info(String format, Object arg1, Object arg2) {
		info.info(format, arg1, arg2);
	}

	public static void info(String format, Object... arguments) {
		info.info(format, arguments);
	}

	public static void warn(String msg) {
		warn.warn(msg);
	}

	public static void warn(String format, Object arg) {
		warn.warn(format, arg);
	}

	public static void warn(String format, Object... arguments) {
		warn.warn(format, arguments);
	}

	public static void warn(String format, Object arg1, Object arg2) {
		warn.warn(format, arg1, arg2);
	}

	public static void warn(String msg, Throwable t) {
		warn.warn(msg, t);
	}

	public static void error(String msg) {
		error.error(msg);
	}

	public static void error(String format, Object arg) {
		error.error(format, arg);
	}

	public static void error(String format, Object arg1, Object arg2) {
		error.error(format, arg1, arg2);
	}

	public static void error(String format, Object... arguments) {
		error.error(format, arguments);
	}

	public static void error(String msg, Throwable t) {
		error.error(msg, t);
	}

	public static void recordException(Throwable e) {
		error("get exception", e);
	}

	public static boolean isDebugEnabled() {
		return debug.isDebugEnabled();
	}

	/**
	 * 异常监控方法
	 *
	 * @param msg   异常描述
	 * @param type  异常类型，方便分类统计和过滤
	 * @param owner 方便只关注自己的异常
	 * @param t     异常类，Throwable字类
	 */
	public static void monitorException(int zoneId, String msg, ExceptionMonitorType type, ExceptionOwner owner, Throwable t) {
		exceptionLogger.error( msg, type.toString(), owner.getMail(), zoneId, t);
	}

	public static void monitorException(int zoneId, String msg, ExceptionMonitorType type, ExceptionOwner owner, long uid, Throwable t) {
		exceptionLogger.error( msg, type.toString(), owner.getMail(), zoneId, uid, t);
	}

	public static void monitorException(int zoneId, String msg, ExceptionMonitorType type, ExceptionOwner owner) {
		exceptionLogger.error(msg, type.toString(), owner.getMail(), zoneId);
	}

	public static void monitorException(int zoneId, String msg, ExceptionMonitorType type, ExceptionOwner owner, long uid) {
		exceptionLogger.error(msg, type.toString(), owner.getMail(), zoneId , uid);
	}
}
